package com.mytaobao.main.cart.func.cart;


import com.baseproject.datasource.local.database.dao.annotation.DbField;
import com.baseproject.datasource.local.database.dao.annotation.DbTable;

/**
 * 服务器返回接收类型，两个表联合查询的结果
 */
@DbTable()
public class ItemCommodity {
    @DbField()
    int commodityId;
    @DbField()
    String imageUrl;
    @DbField()
    String intro;
    @DbField()
    String colorClassification;
    @DbField()
    String size;
    @DbField()
    String taoCanType;
    @DbField()
    float priceNow;
    @DbField()
    float priceBefore;
    @DbField()
    int countInCart;
    /** 类型 1:普通浏览 2：购物车 3： 待付款，4：待发货，5：待收货, 6: 待评价 7：退款/售后 */
    @DbField()
    int type;
    /** 是否失效,0删除(失效),1正常 */
    @DbField()
    int status;
    @DbField()
    int belongToShopId;
    @DbField()
    int stock;

    //属于shop的字段
    @DbField()
    int shopCartId;
    @DbField()
    String name;
    @DbField()
    boolean ifShopTianMao;



    ////////////////////以下非数据库字段
    /** 是否被选中 */
    private boolean isChildSelected = false;

    private boolean isInEditMode = false;

    /**
     * @return 返回是否修改成功，如果为false说明已经为为1个，不能再减少，需要给用户提示
     */
    public boolean reduceCountInCart() {
        if(countInCart > 1) {
            countInCart--;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @return 返回是否修改成功，如果为false说明已经为为库存最大数，不能再增加，需要给用户提示
     */
    public boolean addCountInCart() {
        if(countInCart < stock) {
            countInCart++;
            return true;
        } else {
            return false;
        }
    }


    //////以下为getter setter


    public boolean isInEditMode() {
        return isInEditMode;
    }

    public void setInEditMode(boolean inEditMode) {
        isInEditMode = inEditMode;
    }

    public int getCommodityId() {
        return commodityId;
    }

    public void setCommodityId(int commodityId) {
        this.commodityId = commodityId;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public String getColorClassification() {
        return colorClassification;
    }

    public void setColorClassification(String colorClassification) {
        this.colorClassification = colorClassification;
    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

    public String getTaoCanType() {
        return taoCanType;
    }

    public void setTaoCanType(String taoCanType) {
        this.taoCanType = taoCanType;
    }

    public float getPriceNow() {
        return priceNow;
    }

    public void setPriceNow(float priceNow) {
        this.priceNow = priceNow;
    }

    public float getPriceBefore() {
        return priceBefore;
    }

    public void setPriceBefore(float priceBefore) {
        this.priceBefore = priceBefore;
    }

    public int getCountInCart() {
        return countInCart;
    }

    public void setCountInCart(int countInCart) {
        this.countInCart = countInCart;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getBelongToShopId() {
        return belongToShopId;
    }

    public void setBelongToShopId(int belongToShopId) {
        this.belongToShopId = belongToShopId;
    }

    public int getShopCartId() {
        return shopCartId;
    }

    public void setShopCartId(int shopCartId) {
        this.shopCartId = shopCartId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isIfShopTianMao() {
        return ifShopTianMao;
    }

    public void setIfShopTianMao(boolean ifShopTianMao) {
        this.ifShopTianMao = ifShopTianMao;
    }

    public boolean isChildSelected() {
        return isChildSelected;
    }

    public void setChildSelected(boolean childSelected) {
        isChildSelected = childSelected;
    }
}
